import matplotlib.pyplot as plt
import numpy as np

# 数据定义，更正为直接对应关系
data_corrected = {
    (500, 2000): 23200,
    (500, 5000): 25150,
    (500, 10000): 28400,
    (1000, 2000): 45650,  # 假设的值，用于演示如何添加更多数据点
    (1000, 5000): 47600,  # 同上
    (1000, 10000): 50850,  # 同上
    (2000, 2000): 90550,
    (2000, 5000): 92500,
    (2000, 10000): 95750
    # 可以继续添加其他数据点...
}

# 提取CLAP和PLAC的唯一值，假设它们是有序的
clap_unique = sorted({clap for clap, _ in data_corrected.keys()})
plac_unique = sorted({plac for _, plac in data_corrected.keys()})

# 准备坐标和高度数据
xpos, ypos, dz = [], [], []
for (clap, plac), tac in data_corrected.items():
    xpos.append(clap)
    ypos.append(plac)
    dz.append(tac)

xpos, ypos = np.array(xpos), np.array(ypos)
zpos = np.zeros_like(dz)  # z轴起始位置为0

# 创建图形和3D坐标轴
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')

# 绘制3D柱状图
dx = dy = 0.5 * 200  # 柱子的宽度和深度
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, zsort='average', shade=True)

# 设置标签和标题
ax.set_xlabel('CLAP')
ax.set_ylabel('PLAC')
ax.set_zlabel('TAC Value')
ax.set_title('3D Bar Chart of TAC by CLAP and PLAC')

# 调整视角
ax.view_init(elev=25, azim=-35)

# 显示图表
plt.show()
